import type {
  ArticleParams,
  ArticleItem,
  ArticlePageParams,
  ArticlePageResult,
  AdjacentArticles
} from './model'

const path = '/api/blog/article'
export const articleAPI = {
  search: (data: ArticleParams) => {
    return useCustomFetch<ArticleItem[]>(`${path}`, {
      method: 'GET',
      params: data
    })
  },
  page: (data: ArticlePageParams) => {
    return useCustomFetch<ArticlePageResult>(`${path}/page`, {
      method: 'GET',
      params: data
    })
  },
  detail: (id: number) => {
    return useCustomFetch<ArticleItem>(`${path}/${id}`, {
      method: 'GET'
    })
  },
  hot: () => {
    return useCustomFetch<ArticleItem[]>(`${path}/hot`, {
      method: 'GET'
    })
  },
  getAdjacentArticles: (id: number) => {
    return useCustomFetch<AdjacentArticles>(`${path}/getAdjacentArticles/${id}`, {
      method: 'GET'
    })
  }
}
